

import bpy
import numpy as np



class C_物体组元素(bpy.types.PropertyGroup):
	value = bpy.props.PointerProperty(type=bpy.types.Object)

class C_2D_物体组元素(bpy.types.PropertyGroup):
	value = bpy.props.CollectionProperty(type=C_物体组元素)
#t_1D物体容器 = bpy.props.CollectionProperty(type=C_物体组元素)
#t_2D物体容器 = bpy.props.CollectionProperty(type=C_2D_物体组元素)


class C_数组元素_B(bpy.types.PropertyGroup):
	value = bpy.props.BoolProperty()

class C_数组元素_i(bpy.types.PropertyGroup):	
	value = bpy.props.IntProperty()

class C_数组元素_f(bpy.types.PropertyGroup):	
	value = bpy.props.FloatProperty()

class C_列表_Str元素(bpy.types.PropertyGroup):	
	value = bpy.props.StringProperty()

class C_列表_粒子系统元素(bpy.types.PropertyGroup):	
	value = bpy.props.PointerProperty(type=bpy.types.ParticleSettings)

class C_2D列表_粒子系统元素(bpy.types.PropertyGroup):	
	value = bpy.props.CollectionProperty(type=C_列表_粒子系统元素)











class C_数组_矩阵4X4(bpy.types.PropertyGroup):
	value = bpy.props.FloatVectorProperty(size=16)

class C_2D_矩阵4X4(bpy.types.PropertyGroup):
	value = bpy.props.CollectionProperty(type=C_数组_矩阵4X4)











class C_图像数据(bpy.types.PropertyGroup):
	value = bpy.props.PointerProperty(type=bpy.types.Image)

class C_2D_图像数据(bpy.types.PropertyGroup):
	value = bpy.props.CollectionProperty(type=C_图像数据)






class C_纹理数据(bpy.types.PropertyGroup):
	value = bpy.props.PointerProperty(type=bpy.types.Texture)

class C_2D_纹理数据(bpy.types.PropertyGroup):
	value = bpy.props.CollectionProperty(type=C_纹理数据)





########################################################
# 材质容器
#######################################################
class C_材质数据(bpy.types.PropertyGroup):
	value = bpy.props.PointerProperty(type=bpy.types.Material)

class C_2D_材质数据(bpy.types.PropertyGroup):
	value = bpy.props.CollectionProperty(type=C_材质数据)









########################################################
# 网格容器
#######################################################
class C_网格数据(bpy.types.PropertyGroup):
	value = bpy.props.PointerProperty(type=bpy.types.Mesh)

class C_2D_网格数据(bpy.types.PropertyGroup):
	value = bpy.props.CollectionProperty(type=C_网格数据)








def f_C_数组元素Copy(objArray, listArray):
	objArray.clear()
	for i in listArray:
		item = objArray.add()
		item.value = i

def f_C_数组元素Copy_列表元素(objArray, listArray):
	objArray.clear()
	for i in listArray:
		item = objArray.add()
		item.value = i.value

def f_C_数组元素Add(objArray, listArray):
	for i in listArray:
		item = objArray.add()
		item.value = i

def f_C_数组元素Add_列表元素(objArray, listArray):
	for i in listArray:
		item = objArray.add()
		item.value = i.value















def f_1D_物体组元素转list(data):
	l = []
	for i in data:
		l.append(i.value)
	return l

def f_2D_物体组元素转list(data):
	k = []
	for i in data:
		k.append( f_1D_物体组元素转list(i.value) )
	return k








def f_set_1D_物体组元素(obj, data):
	obj.clear()
	for i in data:
		item = obj.add()
		item.value = i
		#print(' -- i == ', i, item.value)

def f_set_2D_物体组元素(obj, data):
	obj.clear()

	try:
		len(data[0])
		for i in data:
			item = obj.add()
			item.value
			f_set_1D_物体组元素(item.value, i)
			
	except:
		if len(data):
			item = obj.add()
			item.value
			f_set_1D_物体组元素(item.value, data)
			
		
	









def f_bl_1D物体组_add(obj, value):
	x维度 = len(value)
	for i in range(x维度):
		item = obj.add()
		item.value = value[i]

def f_bl_2D物体组_add(obj, value):
	try:
		y维度 = len(value[0])
		y维度 = len(value)
		if y维度 :
			for i in range(y维度):
				item = obj.add()
				f_bl_1D物体组_add(item.value, value[i])
	except :
		item = obj.add()
		f_bl_1D物体组_add(item.value, value)
	
	















def f_bl_1D物体组_get(obj, key):
	L = []
	if key < 0 :
		for i in range(len(obj)):
			L.append(obj[i].value)
	else:
		L.append(obj[key].value)

	return L

def f_bl_2D物体组_get(obj, key=[]):
	L = []
	if key[0] < 0:
		for i in range(len(obj)):
			L.append( f_bl_1D物体组_get(obj[i].value, key[1]) )
	else:
		L.append( f_bl_1D物体组_get(obj[i].value, key[1]) )

	return L










E_数据类型枚举 = [
	("i", "int", "", 0),
	("f", "float", "", 1),
	("s", "string", "", 2),
	("o", "object", "", 3),
]



classes = (
	C_物体组元素,
	C_数组元素_B,
	C_数组元素_i,
	C_数组元素_f,

	
	C_数组_矩阵4X4,
	C_2D_矩阵4X4,

	
	C_列表_Str元素,
	C_列表_粒子系统元素,
	C_2D列表_粒子系统元素,

	C_2D_物体组元素,



	C_图像数据,
	C_2D_图像数据,

	C_纹理数据,
	C_2D_纹理数据,

	C_材质数据,
	C_2D_材质数据,
	

	C_网格数据,
	C_2D_网格数据,
	
)

def register():
	for c in classes:
		bpy.utils.register_class(c)
		

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)

